package com.meixiang.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

import com.meixiang.R;
import com.meixiang.main.MainActivity;

/**
 * 欢迎页面(闪屏页)
 *
 * @author LZRUI
 */
public class WelcomeActivity extends AppCompatActivity {

    private Handler handler;
    private Runnable jumpRunnable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN); // 隐藏信号栏
        setContentView(R.layout.activity_welcome);
        jumpRunnable = new Runnable() {

            @Override
            public void run() {
                Intent intent = new Intent();
                intent.setClass(WelcomeActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            }
        };
        handler = new Handler();
        handler.postDelayed(jumpRunnable, 3000);
    }

    @Override
    protected void onDestroy() {
        handler.removeCallbacks(jumpRunnable);
        super.onDestroy();
    }
}
